package edu.online.dal;

import edu.online.entity.SwitchOrderEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface SwitchOrderEntityMapper {
    @Delete({
        "delete from switchorder",
        "where SwitchOrderID = #{switchorderid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String switchorderid);

    @Insert({
        "insert into switchorder (SwitchOrderID, AdminUserId, ",
        "RequestTime, ConfirmTime)",
        "values (#{switchorderid,jdbcType=CHAR}, #{adminuserid,jdbcType=CHAR}, ",
        "#{requesttime,jdbcType=TIMESTAMP}, #{confirmtime,jdbcType=TIMESTAMP})"
    })
    int insert(SwitchOrderEntity record);

    @InsertProvider(type=SwitchOrderEntitySqlProvider.class, method="insertSelective")
    int insertSelective(SwitchOrderEntity record);

    @Select({
        "select",
        "SwitchOrderID, AdminUserId, RequestTime, ConfirmTime",
        "from switchorder",
        "where SwitchOrderID = #{switchorderid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="SwitchOrderID", property="switchorderid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="AdminUserId", property="adminuserid", jdbcType=JdbcType.CHAR),
        @Result(column="RequestTime", property="requesttime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="ConfirmTime", property="confirmtime", jdbcType=JdbcType.TIMESTAMP)
    })
    SwitchOrderEntity selectByPrimaryKey(String switchorderid);

    @UpdateProvider(type=SwitchOrderEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SwitchOrderEntity record);

    @Update({
        "update switchorder",
        "set AdminUserId = #{adminuserid,jdbcType=CHAR},",
          "RequestTime = #{requesttime,jdbcType=TIMESTAMP},",
          "ConfirmTime = #{confirmtime,jdbcType=TIMESTAMP}",
        "where SwitchOrderID = #{switchorderid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(SwitchOrderEntity record);
}